#ifndef __L206_H__
#define __L206_H__
#include "stm32f10x.h"

#define COM_L206        COM3

typedef struct {
    uint32_t longitude;
    uint32_t latitude;
} Location;

void l206_init(void);
void l206_reset(void);
uint8_t l206_poweron(void);
void l206_poweroff(void);
void l206_write(char *buf);
void l206_set_baudrate(void);
void l206_cgmr(void);
void l206_cgsn(void);
void l206_csq(void);
uint8_t l206_cpin(void);
void l206_iccid(void);
uint8_t l206_creg(void);
uint8_t l206_cgatt(void);
//send buf to server by tcp socket
uint8_t l206_send(uint8_t *buf, uint16_t len);
uint8_t l206_location_init(void);
//get location
uint8_t l206_get_location(Location *location);
//connect to remote server
uint8_t l206_connect(const char *host, uint32_t port);
//connect http connection
uint8_t l206_http_connect(const char *host, uint32_t port);
void l206_http_get(void);

uint8_t l206_wait_rsp(char *ack, uint16_t timeout);
uint16_t l206_read_rsp(char *ack, char *data, uint16_t timeout);
void l206_start_timer(uint16_t timeout);
void l206_stop_timer(void);
uint8_t l206_is_connected(void);
void l206_lock(void);
void l206_unlock(void);
char *l206_get_imei(void);
uint8_t is_suspend(void);

static void l206_task(void *p_arg);
static void l206_timer_callback(void *p_arg);

extern OS_FLAG_GRP FLAG_TaskRunStatus;
#endif
